var currentImage;
var currentIndex = -1;
var interval;
function showImage(index,title){
	if(index < $('#bigPic img').length){
		var indexImage = $('#bigPic img')[index]
		//var abc = "aaa";$('#bigPic img')[index].attr('titl');
		if(currentImage){   
			if(currentImage != indexImage ){
				$(currentImage).css('z-index',2);
				clearTimeout(myTimer);
				$(currentImage).fadeOut(250, function() {
					myTimer = setTimeout("showNext()", 3000);
					$(this).css({'display':'none','z-index':1})
				});
			}
		}
		$(indexImage).css({'display':'block', 'opacity':1});
		$("#pictitle h3").html(title);
		currentImage = indexImage;
		currentIndex = index;
		$('#thumb li').removeClass('active');
		$($('#thumb li')[index]).addClass('active');
	}
}
function showNext(){
	var len = $('#bigPic img').length;
	var tit = $('#thumb li img').eq(currentIndex+1).attr('title');
	var next = currentIndex < (len-1) ? currentIndex + 1 : 0;
	showImage(next,tit);
}
var myTimer;
$(document).ready(function() {
	myTimer = setTimeout("showNext()", 3000);
	title = $('#thumb li').eq(0).attr('name');
	showNext(title); //loads first image
	$('#thumb li').bind('click',function(e){
		var count = $(this).attr('rel');
		var title = $(this).attr('name');
		showImage(parseInt(count)-1,title);
	});
});
$('#thumb li').css("margin-left","0px");
$(function() {
	$("#bookdate").datepicker({
		minDate: 0
	});
	$("#startdate").datepicker({
		minDate: 0
	});
});
$(document).ready(function(){
    $show = $(".tour_shows");
    $items = $("#menutab ul li a");
    $show.eq(0).show();
    $items.click(function(){
        $(".selected").removeClass("selected");
        $(this).addClass("selected");
        $val = $(this).attr("name");
        $show.hide();
        $show.eq($val).show();
        return false;
    });
});
$(document).ready(function() {
	$("ul.ltitab a:first").addClass("active");
	$stt = $("ul.ltitab a:first").attr("name");
	$("div.ltine_bot_items").eq($stt-1).show(); 
	$(".chon").change(function() {
		$val = $(this).val();
		$("ul.ltitab a").removeClass("active")
		$(this).addClass("active");
		$("div.ltine_bot_items").hide();
		$("div.ltine_bot_items").eq($val-1).fadeIn("slow");
		return false;
	});
});
$(document).ready(function(){
	$("a.acondition").live("click",function(){
		$i = $(this).attr("name");
		$(".divrinfo"+$i).hide();
		//$("body").css("opacity","0.5");
		$(".divcondition"+$i).show();
	});
	$("body").click(function(){
		$(".roomcon").hide();
		$(".roomsv").hide();
		//$("body").css("opacity","1");
	});
	$("a.arinfo").live("click",function(){
		$i = $(this).attr("name");
		$(".divcondition"+$i).hide();
		$(".divrinfo"+$i).fadeIn();
	});
});
function changes() {
	var dates = $('#rate_tour').val();
	var startdate = $('#startdate').val();
	$("#show_room").html("");
	$("#shows").hide();
	$.ajax({
		type: "post",
		url: links+"home/ajax/add_date",
		data: {
			stardate:startdate, date:dates
		},
		success: function(data){
			if(dates != 0){
				$('#endate').html(data);
				$('#todate').html(data);
			}else{
				alert("Please select a program!");
				return false;
			}
		}
	});
}
function checkrate(){
	if(document.getElementById("rate_tour").value == 0){
		alert("Please select a program");
		return false;
	}
}
$(document).ready(function() {
	$(".various1").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});
});
$(function() {
    $("#date1").datepicker();
    $("#date_b").datepicker();
    $("#date_cus").datepicker();
    $("a.example1").fancybox();
});